This page last changed on Jan 08, 2007 by djguvnor.

In the absence of a watermarking feature in Geoserver here's a simple PHP script to do the job.  It has the added bonus that it acts as a proxy for geoserver and enables you to keep geoserver behind the firewall and not open an additional port for it if you wanted to.

 The code just adds two instances of a simple text string over the image and assumes the image will be 256px square since it was developed for use with the google maps API.

<?php
header("Content-type: image/png");
$string = 'Watermark Text';
$wmsurl = 'http://geoserver:8080/geoserver//wms?';

// get the image from geoserver
$im    = imagecreatefrompng($wmsurl . $_SERVER['QUERY_STRING']);

// create a colour including opacity (last param)
$grey = imagecolorallocatealpha ($im, 170, 170, 170, 50);

// write a string in the top left hand corner of the picture
imagestring($im, 5, 50, 50, $string, $grey);

// and again on the bottom right corner
// note, x co-ord is 256 (picture width) - 30 pixels (spacing) - 5 * string length (to make room for the string)
imagestring($im, 5, (256-50)-(strlen($string) * 9), imagesy($im) - 60, $string, $grey);

imagepng($im);
imagedestroy($im);
?> 

  For an example of merging images see:  http://www.sitepoint.com/article/watermark-images-php

Document generated by Confluence on Jan 16, 2008 23:28